package com.dg11185.nearshop.net.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.dg11185.nearshop.net.entity.NewActivity;

/**
 * @author：Daibo    
 * @time：2014-8-8 上午10:54:24
 */
public class NewActivityResponse {

    public NetStatus status = null;

    public List<NewActivity> activities = null;

    public NewActivityResponse() {
        activities = new ArrayList<NewActivity>();
    }

    public void parseJson(String response) {
        try {
            JSONObject object = new JSONObject(response);
            status = NetStatus.getStatus(object.optString("showType"));

            if (!object.isNull("activityList")) {
                JSONArray array = object.optJSONArray("activityList");
                for(int a=0; a<array.length(); a++){
                    NewActivity activity = new NewActivity();
                    activity.parseEntity(array.getJSONObject(a));
                    activities.add(activity);
                }
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
